package ar.edu.unq.tpi.uis.tepe3.wicket.pages;

import java.util.HashMap;

import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.behavior.AbstractBehavior;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.PageLink;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.CompoundPropertyModel;

/**
 * Homepage
 */
public class LayoutPage extends WebPage  {
	
	private HashMap<String, WebMarkupContainer > spanMap = new HashMap<String, WebMarkupContainer>();
	
    public LayoutPage() {
    	super();
		this.addMenu();
	}
    
    public LayoutPage(CompoundPropertyModel propertyModel){
    	super(propertyModel);
    	this.addMenu();
    }
    
    
    
	protected void addMenu() {
		
		WebMarkupContainer homeSpan = new WebMarkupContainer("homeSpan");
		homeSpan.add(new PageLink("homeLink", HomePage.class));
		this.add(homeSpan);
		this.spanMap.put("home", homeSpan);
		
		
		WebMarkupContainer folderSpan = new WebMarkupContainer("folderSpan");
		folderSpan.add(new PageLink("folderLink", FolderPage.class));
		this.add(folderSpan);
		this.spanMap.put("folder", folderSpan);
		
		WebMarkupContainer userSpan = new WebMarkupContainer("userSpan");
		userSpan.add(new PageLink("userLink", UserPage.class));
		this.add(userSpan);
		this.spanMap.put("user", userSpan);
		
		WebMarkupContainer groupSpan = new WebMarkupContainer("groupSpan");
		groupSpan.add(new PageLink("groupLink", GroupPage.class));
		this.add(groupSpan);
		this.spanMap.put("group", groupSpan);
		
		//this.add(new PageLink("groupLink", GroupPage.class));
	}
	
	protected void setActiveClass(String key){
		WebMarkupContainer span = this.spanMap.get(key);
		span.add(new AbstractBehavior() {
			@Override
			public void onComponentTag(Component component, ComponentTag tag) {
				tag.put("class", "active");
			}
		});
	}
}
